package com.datatraffic.salesup;



import com.datatraffic.salesup.ListAdapterTasks.ItemHolder;
import com.datatraffic.salesup.model.Form;
import com.datatraffic.salesup.model.Task;
import com.datatraffic.salesup.model.menu_prospectos;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListAdapterMenuProspectos extends ArrayAdapter<menu_prospectos>{	
	
	Context context; 
    int layoutResourceId; 
    menu_prospectos data[] = null;
	
	public ListAdapterMenuProspectos(Context context, int layoutResourceId, menu_prospectos[] data) {
		super(context, layoutResourceId,data);
		// TODO Auto-generated constructor stub
		this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
	}

	public View getView(int position, View convertView, ViewGroup parent)
	{
		View row = convertView;
		ItemHolder holder = null;

		if(row == null)
		{//Activity
			LayoutInflater inflater = ((Activity)context).getLayoutInflater();
			row = inflater.inflate(layoutResourceId, parent, false);

			holder = new ItemHolder();
			holder.txtTipoCliente=(TextView)row.findViewById(R.id.txttipocliente);
			row.setTag(holder);
		}		
		else
        {
            holder = (ItemHolder)row.getTag();
        }
		
		menu_prospectos item = data[position];
        holder.txtTipoCliente.setText(item.getTipoCliente()); 
        holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
        
        if(item.getTipoCliente().equalsIgnoreCase("CREADO"))
        {
        	holder.imgIcon.setImageResource(R.drawable.iconocreado);
        }
        else if(item.getTipoCliente().equalsIgnoreCase("Contacto-1"))
        {
        	holder.imgIcon.setImageResource(R.drawable.iconocontacto1);
        }
        else if(item.getTipoCliente().equalsIgnoreCase("CONTACTO-2"))
        {
        	holder.imgIcon.setImageResource(R.drawable.iconocontacto2);
        }
        else if(item.getTipoCliente().equalsIgnoreCase("CONTACTO-3"))
        {
        	holder.imgIcon.setImageResource(R.drawable.iconocontacto3);
        }
        else if(item.getTipoCliente().equalsIgnoreCase("VENTA"))
        {
        	holder.imgIcon.setImageResource(R.drawable.iconovendido);
        }
        else if(item.getTipoCliente().equalsIgnoreCase("DECLINADO"))
        {
        	holder.imgIcon.setImageResource(R.drawable.iconodeclinado);
        }
        
        return row;
    }
	
	public void setData(menu_prospectos[] data)
    {
    	this.data=data;
    }
    

	@Override
	public void clear()
	{
		data=new menu_prospectos[]
				{

				};
	}

	static class ItemHolder
	{
		TextView txtTipoCliente;
		ImageView imgIcon;
	}
}